#include <iostream>
#include <string>
#include <vector>
using namespace std;

int solution(std::string input) {
    // Please write your code here
    vector<int> vc(4);
    for (int i = 0; i < input.size(); i++)
    {
        if (input[i] == 'A')
            vc[0]++;
        else if (input[i] == 'D')
            vc[1]++;
        else if (input[i] == 'F')
            vc[2]++;
        else if (input[i] == 'S')
            vc[3]++;
    }
    int ave = input.size() / 4;
    int min = 32767;
    int max = -1;
    for (int i = 0; i < vc.size(); i++)
    {
        if (vc[i] < min)
            min = vc[i];
        if(vc[i] > max)
            max = vc[i];
    }
    int count = (ave - min) > (max - ave) ? ave - min : max - ave;
    return count;
}

//int main() {
//    //  You can add more test cases here
//    std::cout << (solution("ADDF") == 1) << std::endl;
//    std::cout << (solution("ASAFASAFADDD") == 3) << std::endl;
//    return 0;
//}